Show all User accounts in a terminal window
Hi Community,
which CLI command give me a list of all Users of a system?
Thx & Bye Tom
Hi Community,
which CLI command give me a list of all Users of a system?
Thx & Bye Tom
One way would be:
dscl . list /usersAs red_menace shows you can get a raw list of accounts, however many of them are for daemons or specific system file ownership but are not what you might call interactive users. May of them may never be used as your system is not in the correct environment (such as 'nobody' which is typically assigned to a guest NFS user, assuming you were exporting a file system via NFS, which very few Mac OS X users actually do).
You might try using
dscl . list /users shell | grep -v falsewhich will narrow down the list of users a lot.
Then eliminate _uucp, as the "Unix to Unix Copy" facilities are very old and a mystery to setup (I did it once back in '87 on some PDP-11s running AT&T UNIX System V.2, but it was strange even then).
You should be left with:
Guest
root
your_short_username
any_other_accounts_you_created_on_this_macHi Bob,
okay thanks for your explanation. Without the filter argument I see a list of users like I would see in Linux /etc/passwd. I found a couple of arguments for the dscl command like UniqueID etc and this was what I searched. One more question: Where or in which files are this information's stored? Is there a preferences file or something like that?
Thx & Bye Tom
The simplest way to get a list of users with 'home' folders is just to type
ls /Users/
in Terminal.
It might be /var/db/dslocal/nodes/Default/users/*, but I'm am unsure. I did find a bunch of .plist files there that included my account name, and a bunch of the other names from the "dscl . list /Users" command. But that could be something else too :-)
Hi,
softwater wrote:
The simplest way to get a list of users with 'home' folders is just to type
ls /Users/
in Terminal.
this isn't true because a User home directory could be restored from a Time Machine backup without existing the corresponding User on the system. In my case a user did a clean install and restored the users from the old system from a time machine backup but a login failed. With the dscl command I'm able to find out if the user really exists on the system or if only the home directory is present.
Thx & Bye Tom
Hi,
BobHarris wrote:
It might be /var/db/dslocal/nodes/Default/users/*, but I'm am unsure. I did find a bunch of .plist files there that included my account name, and a bunch of the other names from the "dscl . list /Users" command. But that could be something else too :-)
yes I guess that this information's are stored very deep and in multiple files in the system. Nothing with keep it simple and stupid. In Linux I migrate the users from one system to another by moving the /etc/passwd, /etc/shadow and /etc/group file to the new system. It could be just that simple... ;-)
Thx & Bye Tom
Hi,
If it can help, take a look here.
http://www.easy-ict.be/page4/page41/rapidviewer-2/index.html
Bye.
Hi Nicky,
I tried the link but it doesn't exist anymore. I'm curious on the content of the link.
prontosystems wrote:
Where or in which files are this information's stored? Is there a preferences file or something like that?
OS X user data is stored in an LDAP database. Either a file-based LDAP database running locally and with no networking required (the dslocal stuff), or the user data is stored LDAP servers accessed via and running on the network, or the data is stored both in parallel.
If you want to rummage the data, use the dscl tool and/or the LDAP programming interfaces or related. These tools will deal with figuring out what data is stored where, and on any particular system. Whether that data is either stored entirely locally, or in an Open Directory or Active Directory database, or otherwise.
I prefer to get name and associated number for both Users and Groups. This works for me in Terminal.app:
dscl . -list /groups gid # all group names and GID
dscl . -list /users uid # all user names and UID.
Nothing with keep it simple and stupid. In Linux I migrate the users from one system to another by moving the /etc/passwd, /etc/shadow and /etc/group file to the new system
It's even simpler. Nightly the dslocal and shadow directories are backed up. Restore /private/var/db/dslocal-backup.xar and /private/var/db/shadow-backup.xar from your backup. This should be done in Single User mode.
Show all User accounts in a terminal window